package com.dyp.h2_demo.service;

import com.dyp.h2_demo.entity.Person;
import com.dyp.h2_demo.repository.PersonRepository;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.Optional;

@Service
public class PersonService {
    @Autowired
    private PersonRepository personRepository;

    public Optional<Person> findById(long id) {
        return personRepository.findById(id);
    }

    @Transactional
    public void updateById(Long id, String name) {
        personRepository.updateById(id, name);
    }
}
